package com.krain.ddbb.fragment;

import android.app.Activity;
import android.widget.EditText;

import com.krain.ddbb.R;
import com.krain.ddbb.entity.AppApi;
import com.krain.ddbb.entity.BaseEntity;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

/**
 * Created by 胡亚敏 on 2016/3/15 0015.
 */
@EFragment(R.layout.view_unbindcard)
public class UnBindedCardFragment extends BaseFragment {
    @ViewById(R.id.act_et_cardnum)
    EditText mEtCardNum;
    @ViewById(R.id.act_et_cardname)
    EditText mEtBank;


    @Click(R.id.act_bindcard_submit)
    void sumitToBindCard() {
        mBaseActivity.showProgressDialog();
        if (mEtBank.getText().length() == 0 || mEtCardNum.getText().length() == 0) {
            baseUtil.showSnackBar(mBaseActivity, "信息填写不完整");
            return;
        }
        bindCard();

    }

    @Background
    void bindCard() {
        BaseEntity entity = AppApi.getsInstance(mBaseActivity).bindUserCard(app.getmUserinfo().getAccess_token(), mEtCardNum.getText().toString(), mEtBank.getText().toString());
        if (entity != null) {
            baseUtil.showSnackBar(mBaseActivity, "添加成功");
            mBaseActivity.setResult(Activity.RESULT_OK);
            mBaseActivity.finish();
        }
        mBaseActivity.dismissProgressDialog();
    }


}
